{extend name="index_layout"/}
{block name="main"}
<link href="/static/libs/formSelects-v4.css" rel="stylesheet" />
<script src="/static/libs/formSelects-v4.js"></script>
<form class="layui-form" method="post">
    
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="bitian">*</span>部门编码 </label>
        <div class="layui-input-block">
            <input type="text" name="nums" value="{$department.nums}" lay-verify="required" autocomplete="off" placeholder="请输入部门编码" class="layui-input layui-disabled">
        </div>
    </div>
    <input type="hidden" name="id" value="{$department.id}">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="bitian">*</span>部门名称 </label>
        <div class="layui-input-block">
            <input type="text" name="title" value="{$department.title}" lay-verify="required" autocomplete="off" placeholder="请输入部门名称" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户 </label>
        <div class="layui-input-block">
            <select name="user_id" id="" class="mutiple-select" xm-select-search=""  xm-select="userDetailOrganizationSelectId">
                {volist name="adminUser" id="item"}
                <option value="{$item.id}">{$item.nickname}</option>
                {/volist}
            </select>
        </div>
    </div>

    
    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter='ds' type="button" data-refresh="false">立即提交</button>
            <button class="layui-btn layui-btn-normal" type="button" onclick="var index1 = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index1);">返回</button>
        </div>
    </div>
</form>

{/block}

{block name="script"}
<script>
    
    $(function(){
        layui.formSelects.render('userDetailOrganizationSelectId', {
            skin: "normal", //多选皮肤normal|primary|default|danger|warm
            height: "auto",                //是否固定高度, 38px | auto
            radio: false,                  //是否设置为单选模式
            direction: "down",        //显示方式向下显示
            on: function(id, vals, val, isAdd, isDisabled){
            },            //同formSelects.on
        })
        var value = JSON.parse('{:json_encode($user_id)}')
        // console.log(value);
        layui.formSelects.value('userDetailOrganizationSelectId',value);
    })
    layui.use(['form'], function() {
        var form = layui.form;
        form.on('submit(ds)',function(data){
            var param = data.field;
            $.post('{:url("editPost")}',param,function(res){
                if(res.code > 0){
                    layer.msg('修改成功');
                    setTimeout(() => {
                        var index1 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index1);
                        parent.location.reload();
                    }, 500);
                }else{
                    layer.msg(res.msg);
                }
            },'json');
        })
    })
</script>
{/block}